import os

import cv2
import numpy as np
from option import parse_args

if __name__ == '__main__':
    args = parse_args()
    diffs = os.path.join(args.root_dir, 'diffs')

    videos = open('unaligned_videos_statistics.dat').readlines()
    for video in videos:
        video_split = video.split('.')
        video_path = os.path.join(diffs, video_split[0])
        if not os.path.exists(video_path):
            continue
        for crop in os.listdir(video_path):
            mask = cv2.imread(os.path.join(video_path, crop), cv2.IMREAD_GRAYSCALE)
            print('{:.2f}'.format(np.mean(mask)), end=',')
        print()
